package com.sgcc.statistics.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.statistics.domain.CCons;
import com.sgcc.statistics.service.ICConsService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * CConsController
 * 
 * @author sgcc
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/CCons")
public class CConsController extends BaseController
{
    @Autowired
    private ICConsService cConsService;

    /**
     * 查询CCons列表
     */
    //@PreAuthorize(hasPermi = "statistics:CCons:list")
    @GetMapping("/list")
    public TableDataInfo list(CCons cCons)
    {
        startPage();
        List<CCons> list = cConsService.selectCConsList(cCons);
        return getDataTable(list);
    }

    /**
     * 导出CCons列表
     */
    //@PreAuthorize(hasPermi = "statistics:CCons:export")
    @Log(title = "CCons", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CCons cCons) throws IOException
    {
        List<CCons> list = cConsService.selectCConsList(cCons);
        ExcelUtil<CCons> util = new ExcelUtil<CCons>(CCons.class);
        util.exportExcel(response, list, "CCons");
    }

    /**
     * 获取CCons详细信息
     */
    //@PreAuthorize(hasPermi = "statistics:CCons:query")
    @GetMapping(value = "/{consId}")
    public AjaxResult getInfo(@PathVariable("consId") Long consId)
    {
        return AjaxResult.success(cConsService.selectCConsById(consId));
    }

    /**
     * 新增CCons
     */
    //@PreAuthorize(hasPermi = "statistics:CCons:add")
    @Log(title = "CCons", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CCons cCons)
    {
        return toAjax(cConsService.insertCCons(cCons));
    }

    /**
     * 修改CCons
     */
    //@PreAuthorize(hasPermi = "statistics:CCons:edit")
    @Log(title = "CCons", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CCons cCons)
    {
        return toAjax(cConsService.updateCCons(cCons));
    }

    /**
     * 删除CCons
     */
    //@PreAuthorize(hasPermi = "statistics:CCons:remove")
    @Log(title = "CCons", businessType = BusinessType.DELETE)
	@DeleteMapping("/{consIds}")
    public AjaxResult remove(@PathVariable Long[] consIds)
    {
        return toAjax(cConsService.deleteCConsByIds(consIds));
    }
}
